import {
	postUrl,
	post
} from '@/utils/request.js'

/**
 * 我的票夹--全部
 */
export async function postSearch(data) {
	return postUrl(
		`/applet/einvoice/search?einvoiceDate=${data.einvoiceDate}&status=${data.status}&search=${data.search}&pageIndex=${data.pageIndex}&areaCode=${data.areaCode}`
		);
}
/**
 * 单位电子票据
 */
export async function postUnitsearch(data) {
	return postUrl(
		`/applet/einvoice/unitsearch?einvoiceDate=${data.einvoiceDate}&status=${data.status}&search=${data.search}&pageIndex=${data.pageIndex}&agencyId=${data.agencyId}&cantonId=${data.cantonId}`
		);
}
//获取票据图片
export async function postShow(data) {
  return postUrl(`/applet/einvoice/show?einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}&randomNumber=${data.randomNumber}&pageIndex=${data.pageIndex}`);
}
/**
* 邮件发送
*/
export async function postEmail (data) {
  return postUrl(`/applet/send/email?email=${data.email}&einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}&randomNumber=${data.randomNumber}&randNum=${data.randNum}`);
}

/**
 * 区块链显示
 * */
export async function qklMessage(data) {
  return postUrl(`/applet/einvoice/detailblock?einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}`);
}

/**
* 二维码生成
*/
export async function postGetqrcode(data) {
  return postUrl(`/applet/einvoice/getqrcode?einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}&randomNumber=${data.randomNumber}`);
}
/**
* 票据挂接
*/
export async function postGiveuser(data) {
  return postUrl(`/applet/einvoice/giveuser?einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}&randomNumber=${data.randomNumber}`);
}
/**
* 扫码二维码接口
*/
export async function postEinvoiceQrcode(str) {
   let param = '';
  if(str.indexOf('#')>0){
    param='?'+str.replace(/#/g,'&').replace(/-/g,'=').replace('einvoiceCode','ec').replace('einvoiceNumber','en').replace('randomNumber','rn');
  }else{
    param='?param='+str
  }
  return postUrl(`/applet/einvoice/qrcode`+param);
}
//未认证查询票据详情
export async function postCheckDetail(data) {
	return postUrl(`/applet/einvoice/detail?einvoiceCode=${data.einvoiceCode}&einvoiceNumber=${data.einvoiceNumber}&randomNumber=${data.randomNumber}`);
}
//已认证查询票据详情
export async function crossProQueryEInvoiceDetail(data) {
	let params={
		...data,
		eInvoiceCode:data.einvoiceCode,
		eInvoiceNumber:data.einvoiceNumber,
		issueDate:data.issueDate.replace(/-/g, '')
	}
	delete params.einvoiceCode;
	delete params.einvoiceNumber;
	return post('/applet/reimbursement/person/crossProQueryEInvoiceDetail',params)
}
//外省邮件发送

export async function sendEmailOut(data) {
	return post(`/applet/reimbursement/person/sendEmailOut`,data);
}